package actions;

import game.constants.ReferenceObject;
import game.constants.ReferenceSpecialFeature;
import objects.SpetialFeature;
import objects.WorldObject;
import universe.Universe;
import constants.Constants;


public class ActionReciveAttackTree extends ActionReciveAttack{
	
	@Override
	public boolean processActionChild(Universe universe) {
		
		System.out.println("Recive Attack tree");
		
		if(damage==0){return false;}
		
		WorldObject axe = source.getObjectFromList(ReferenceObject.OBJECT_REFERENCE_AXE);
		
		if (axe==null){return false;}
		
		SpetialFeature equipep = axe.getFeature(ReferenceSpecialFeature.SPETIAL_FEATURE_OBJECT_EQUIPED);
		
		if(equipep.getValue()==Constants.FALSE){
			return false;
		}
		
		for(SpetialFeature feature : target.getListFeatures()){
			if(feature.getId()==ReferenceSpecialFeature.SPETIAL_FEATURE_CURRENT_LIFE){
				feature.setValue(feature.getValue()-damage);
				System.out.println("Proceso Action Recive Ataak1");
				return true;
			}
		}
		System.out.println("Proceso Action Recive Ataak TREE2");
		return false;

	}
	
	@Override
	public ActionReciveAttackTree cloneAction(){
		ActionReciveAttackTree action = new ActionReciveAttackTree();
		action.modifyAction(this);
		return action;
		
	}

}
